<?php
session_start();
include("classes/conn.php");
$num=$_POST['num'];
$psw=$_POST['psw'];
$role=$_POST['role'];
if($role=="teacher"){
    $query="select num,psw from teacher where num='".$num."' and psw='".$psw."'";
    $result=mysql_query($query);
    if(mysql_fetch_array($result)){
        $_SESSION['t_num']=$num;
        $_SESSION['psw']=$psw;
        $_SESSION['role']=$role;
        echo "teacher1";
    }
    else{
        echo "0";
    }
}
if($role=='stu'){
    $class=$_POST['class'];
    $query="select num,psw from student where num='{$num}' and psw='{$psw}' and class='{$class}'";
    $res=mysql_query($query);
    if(mysql_num_rows($res)){
        $_SESSION['stu_num']=$num;
        $_SESSION['role']=$role;
        $_SESSION['psw']=$psw;
        echo 'stu1';
    }
}
mysql_close($conn);

